package com.qf.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qf.entity.TlCar;
import com.qf.utils.ResultMsg;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

public interface CarMapper extends BaseMapper<TlCar> {


    //查询车次时间
    @Select("SELECT c.car_starttime,c.car_endtime FROM tl_car c where c.car_name=#{name}")
    TlCar findOneByName(String carName);

    //根据城市名字查询车次编号
    @Select("SELECT c.car_id FROM tl_car c,tl_center ce,tl_city ct WHERE c.car_id=ce.car_id AND ce.city_id=ct.city_id AND ct.city_name=#{name}")
    List<Integer> findByCityName(String cityName);


    @Select("SELECT * FROM tl_car WHERE car_startaddr=#{arg0} AND car_endaddr=#{arg1} AND car_starttime > #{arg2} AND car_starttime < DATE_ADD(#{arg2}, INTERVAL 1 DAY)")
    List<TlCar> findByStarttime(String carStartaddr, String carEndaddr, Date date);


}
